<?php


namespace pcompects\http;
use Psr\Http\Message;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UriInterface;

class Request implements Message\RequestInterface,UriInterface
{
    /**
     * @var array $_SERVER
     */
    protected $clientServer =[];
    /**
     * @var array  getallheaders
     */
    protected $clientHeader =[];

    public function __construct()
    {
        $this->clientServer = $_SERVER;

        $this->clientHeader = getallheaders();
    }

    /**
     * 获取http协议版本
     * @inheritDoc
     */
    public function getProtocolVersion()
    {
        return strtolower($this->clientServer['SERVER_PROTOCOL']);
    }

    /**
     * @inheritDoc
     */
    public function withProtocolVersion($version)
    {
        // TODO: Implement withProtocolVersion() method.

    }

    /**
     * 获取请求头数据
     * @inheritDoc
     */
    public function getHeaders()
    {
        return $this->clientHeader;
    }

    /**
     * @inheritDoc
     * @return boolean
     */
    public function hasHeader($name)
    {
        return isset($this->clientHeader[$name]);
    }

    /**
     * @inheritDoc
     */
    public function getHeader($name)
    {
        return $this->hasHeader($name) ? $this->clientHeader[$name] :'';
    }

    /**
     * @inheritDoc
     */
    public function getHeaderLine($name)
    {
        // TODO: Implement getHeaderLine() method.
    }

    /**
     * @inheritDoc
     */
    public function withHeader($name, $value)
    {
        // TODO: Implement withHeader() method.
    }

    /**
     * @inheritDoc
     */
    public function withAddedHeader($name, $value)
    {
        // TODO: Implement withAddedHeader() method.
    }

    /**
     * @inheritDoc
     */
    public function withoutHeader($name)
    {
        // TODO: Implement withoutHeader() method.
    }

    /**
     * @inheritDoc
     */
    public function getBody()
    {
        // TODO: Implement getBody() method.
    }

    /**
     * @inheritDoc
     */
    public function withBody(StreamInterface $body)
    {
        // TODO: Implement withBody() method.
    }

    /**
     * @inheritDoc
     */
    public function getRequestTarget()
    {
        // TODO: Implement getRequestTarget() method.
    }

    /**
     * @inheritDoc
     */
    public function withRequestTarget($requestTarget)
    {
        // TODO: Implement withRequestTarget() method.
    }

    /**
     * 获取请求类型
     * @inheritDoc
     */
    public function getMethod()
    {
        return  strtolower($this->clientServer['REQUEST_METHOD']);
    }

    /**
     * 判断是否为get请求
     * @return bool
     */
    public function isGet()
    {
        return 'get' === $this->getMethod();
    }

    /**
     *判断是否为post请求
     * @return bool
     */
    public function isPost()
    {
        return 'post' === $this->getMethod();
    }
    /**
     * @inheritDoc
     */
    public function withMethod($method)
    {
        // TODO: Implement withMethod() method.
    }

    /**
     * @inheritDoc
     */
    public function getUri()
    {
        return $this->clientServer['REQUEST_URI'];
    }

    /**
     * @inheritDoc
     */
    public function withUri(UriInterface $uri, $preserveHost = false)
    {
        // TODO: Implement withUri() method.
    }

    /**
     * @inheritDoc
     */
    public function getScheme()
    {
        // TODO: Implement getScheme() method.
    }

    /**
     * @inheritDoc
     */
    public function getAuthority()
    {
        // TODO: Implement getAuthority() method.
    }

    /**
     * @inheritDoc
     */
    public function getUserInfo()
    {
        // TODO: Implement getUserInfo() method.
    }

    /**
     * @inheritDoc
     */
    public function getHost()
    {
        // TODO: Implement getHost() method.
    }

    /**
     * @inheritDoc
     */
    public function getPort()
    {
        // TODO: Implement getPort() method.
    }

    /**
     * @inheritDoc
     */
    public function getPath()
    {
        // TODO: Implement getPath() method.
    }

    /**
     * @inheritDoc
     */
    public function getQuery()
    {
        // TODO: Implement getQuery() method.
    }

    /**
     * @inheritDoc
     */
    public function getFragment()
    {
        // TODO: Implement getFragment() method.
    }

    /**
     * @inheritDoc
     */
    public function withScheme($scheme)
    {
        // TODO: Implement withScheme() method.
    }

    /**
     * @inheritDoc
     */
    public function withUserInfo($user, $password = null)
    {
        // TODO: Implement withUserInfo() method.
    }

    /**
     * @inheritDoc
     */
    public function withHost($host)
    {
        // TODO: Implement withHost() method.
    }

    /**
     * @inheritDoc
     */
    public function withPort($port)
    {
        // TODO: Implement withPort() method.
    }

    /**
     * @inheritDoc
     */
    public function withPath($path)
    {
        // TODO: Implement withPath() method.
    }

    /**
     * @inheritDoc
     */
    public function withQuery($query)
    {
        // TODO: Implement withQuery() method.
    }

    /**
     * @inheritDoc
     */
    public function withFragment($fragment)
    {
        // TODO: Implement withFragment() method.
    }

    /**
     * @inheritDoc
     */
    public function __toString()
    {
        // TODO: Implement __toString() method.
    }
}